package mapper

import (
	"github.com/beego/beego/v2/client/orm"
	"ksd-social-api/modules/searchkeywords/model"
)

type SearchKeywordsMapper struct {
}

/**
 * 查找关键词
 * @author feige
 * @date 2024-01-07
 * @version 1.0
 * @desc
 */
func (mapper *SearchKeywordsMapper) FindSearhKeywords(systemId uint64) ([]model.SearchKeywords, error) {
	// 获取数据库链接
	mysql := orm.NewOrm()
	// 准备一个切片容器
	var searchKeywords []model.SearchKeywords
	// 执行查询
	_, err := mysql.Raw("select id,keyword from xk_search_keywords where  is_deleted = 0 and status = 1 and system_id = ? order by sort_num").SetArgs(systemId).QueryRows(&searchKeywords)
	if err != nil {
		return nil, err
	}
	return searchKeywords, nil
}
